#include <iostream>
#include <map>
#include <utility>
#include <vector>

using namespace std;

class Solution {
public:
  bool canJump(vector<int> &nums) {
    /*
      对于某个下标准i
      jump[i] => 距离 D(i)  F(i)代表某个是否可达 F(i) = F(i+1) || F(i+2) || ...
      || F(i+D(i))

      可能存在重复计算，导致冗余，我们使用递归尝试一下

      更简单的方法是，倒序计算
     */

    // expception handle and exit solution
    int length = nums.size();

    if (length == 1) {
      return true;
    }

    int i = 0;
    int max = 0;
    for (i = 0; i < length; i++) {
      if (i + nums[i] > length) {
        max = i + nums[i];
      }
    }

    return length >= max;
  }
};

int main() { return 0; }
